package com.dongxing.concyrrency.chapter3;

import java.util.concurrent.TimeUnit;

/**
 * @author XavierDong
 **/
public class CreateThread5 {


    private static int counter = 1;

    public static void main(String[] args) {

        try {
            for (int i = 0; i < Integer.MAX_VALUE; i++) {

                counter++;

                Thread thread = new Thread(new Runnable() {
                    @Override
                    public void run() {
                        while (true) {
                            try {
                                TimeUnit.SECONDS.sleep(1);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                        }
                    }
                });
                thread.start();
            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("Total created thread nums=>" + counter);
    }
}
